package com.wl.mybootmybatis2.controller;

import com.wl.mybootmybatis2.entity.Emp;
import com.wl.mybootmybatis2.services.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author wl
 * @version 1.0
 * @date 2022/6/14
 * @description:
 */
@RestController
@RequestMapping("/emp")
public class EmpController {

    @Autowired
    private EmpService empService;

    @GetMapping("/getAll")
    public List<Emp> getAll(){
        return empService.getAll();
    }

    @PostMapping("/addEmp")
    public String addEmp(@RequestBody Emp emp){
        return empService.addEmp(emp)+"";
    }
    @PutMapping("/updateEmp")
    public String updateEmp(@RequestBody Emp emp){
        System.out.println(1);
        return String.valueOf(empService.updateEmp(emp));
//        return String.valueOf(1);
    }
    @DeleteMapping("/delEmp/{eno}")
    public String delEmp(@PathVariable("eno") Integer eno){
        return String.valueOf(empService.delEmp(eno));
//        return String.valueOf(1);
    }
}
